/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package newpackage;

/**
 *
 * @author BATAQUERO
 */
public class algoritmo_fuerza_bruta extends Busqueda{

public static int validarFB;

    public static void algoritmoFB(String compararFB){
        
        validarFB=CompararFB(compararFB, LongitudTexto);
        if(validarFB!=-1){   
        MostrarResultados(compararFB);
        TotalCoincidencias++;
        }
    }
    public static int CompararFB(String text, String pattern){
       
        int devuelve = -1;
        int k=0;
        int j=0;
        int i=0;
        while (k + (pattern.length()-1)<text.length()){
        i=0;
        while(i<pattern.length()){
                if(pattern.charAt(i)==text.charAt(i+k)){
                        i++;
                }
                else {
                        break;
                }
        }
        if(i==pattern.length()){
            devuelve+=1;
        }
        k++;
        }
       return devuelve;
    }
}
